﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class RaiseStatementElement : StatementElement
    {
        private VariableExpressionElement error;
        private VariableExpressionElement address;

        public VariableExpressionElement Error { get { return error; } set { error = value; } }
        public VariableExpressionElement Address { get { return address; } set { address = value; } }

        public RaiseStatementElement(TokenInfo StartInfo, VariableExpressionElement Error, VariableExpressionElement Address, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            error = Error;
            address = Address;
        }

        public override string ToString()
        {
            string result = "raise";
            if (error != null)
                result += string.Format(" {0}", error);
            if (address != null)
                result += string.Format(" at {0}", address);
            return result;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (error != null)
                yield return error;
            if (address != null)
                yield return address;
        }
    }
}
